<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>子盒子在父亲里面水平和垂直居中</title>
    <style>
        .father{
            /* 利用flex实现 */
            display: flex;
            /* 主轴水平居中： */
            justify-content: center;
            /* 侧轴水平居中 */
            align-items: center;
            width: 300px;
            height: 300px;
            background-color: pink;
        }
        .son{
            width: 200px;
            height: 200px;
            background-color: purple;
            
        }
    </style>
</head>
<body>
    <div class="father">
    <div class="son"></div>
</div>
</body>
</html>